package com.mdd.mapper;

import com.mdd.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper {
    @Select("select id, book_name booKName, author, publisher from tb_book")
    List<Book> selectAll();

    @Insert("insert into tb_book(book_name, author, publisher) value(#{bookName},#{author},#{publisher})")
    Integer addBook(Book book);

    @Select("select id, book_name booKName, author, publisher from tb_book where id = #{id}")
    Book selectById(Integer id);

    @Update("update tb_book set book_name=#{bookName},author=#{author},publisher=#{publisher} where id = #{id}")
    Integer updateById(Book book);

    @Delete("delete from tb_book where id = #{id}")
    Integer deleteById(Integer id);
}
